package br.com.dbsti.construtortelas;

import javax.swing.JLabel;
import javax.swing.JTextField;
import net.miginfocom.swing.MigLayout;

public class EditorPais extends EditorObjetos<Pais>{

    private JTextField txtId;
    private JTextField txtNome;
    private JTextField txtSigla;
    private JTextField txtCodigoIBGE;
    
    @Override
    protected void preencheCamposTela() {
        this.txtId.setText(valor.getId() != null ? valor.getId().toString() : "");
        this.txtNome.setText(valor.getNome());
        this.txtSigla.setText(valor.getSigla());
        this.txtCodigoIBGE.setText(valor.getCodigoIBGE());
    }

    @Override
    protected void lerCamposTela() {
        this.valor.setId(
                this.txtId.getText().isEmpty()
                ? null
                : Long.valueOf(this.txtId.getText()));
        this.valor.setNome(this.txtNome.getText());
        this.valor.setSigla(this.txtSigla.getText());
        this.valor.setCodigoIBGE(this.txtCodigoIBGE.getText());
        
   
    }

  @Override
    public void adicionarEditoresPropriedades (){      
        
        this.add(new JLabel("ID:"), "cell 0 0");
        this.txtId = new JTextField();
        this.add(this.txtId, "cell 1 0, w 100px");
    
        this.add(new JLabel("Nome:"), "cell 0 1");
        this.txtNome = new JTextField();
        this.add(this.txtNome, "cell 1 1, w 250px");
        
        this.add(new JLabel("Sigla:"), "cell 0 2");
        this.txtSigla = new JTextField();
        this.add(this.txtSigla, "cell 1 2, w 50px");
        
        this.add(new JLabel("Código IBGE:"), "cell 0 3");
        this.txtCodigoIBGE = new JTextField();
        this.add(this.txtCodigoIBGE, "cell 1 3,, w 100px");
        
      
    }
}
